package code._16reflect._07add;

public class Demo {
    public static void main(String[] args) throws ClassNotFoundException, InstantiationException, IllegalAccessException {
        Class<?> c = Class.forName("code._16reflect._07add.A");
        //当有无参构造器时、可以直接实例化
        Object o = c.newInstance();
        System.out.println("o = " + o);
    }
}


class A{
    int a;

    public A(int a) {
        this.a = a;
    }

    public A() {
    }

    @Override
    public String toString() {
        return "A{" +
                "a=" + a +
                '}';
    }
}